package com.xw.service;

import com.xw.mapper.Mymapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@org.springframework.stereotype.Service
public class Service {

    @Autowired
    private Mymapper mymapper;
    @Transactional
    public  void  delete(int id){

         mymapper.delete(id);
        //测试1除0语法错误事务会自动提交回滚,撤销之前的操作
        //测试时前端会报错，查看数据库因为回滚，数据不会被删除
         int  i=1/0;

        System.out.println();
    }
}
